package com.fgchen.util.excel;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Component;

import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2018-04-09.
 */
@Component
public class ExcelConfigFactory {

    public ExcelConfig createExcelConfig(String jsonFilepath) throws Exception {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(jsonFilepath);
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
        ExcelConfig excelConfig = new ObjectMapper().readValue(inputStreamReader, ExcelConfig.class);
        inputStreamReader.close();
        return excelConfig;
    }

}
